package com.example.administrator.myapplication;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;

import com.example.administrator.myapplication.adapter.MyAdapter;

public class CitySelectActivity extends AppCompatActivity {
String[] citys ={"长沙市","株洲市","岳阳市","邵阳市"};
    private ListView cityListView;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_city_select);
        initView();
        initData();
        initEvent();
    }
    private void initView(){
        cityListView = findViewById(R.id.city_select_lv);
        cityListView.setAdapter(new MyAdapter(CitySelectActivity.this,citys));
    } private void initData(){

    } private void initEvent(){
   cityListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
       @Override
       public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
           Intent intent =new Intent();
           intent.putExtra("data",citys[i]);
           setResult(1,intent);
           finish();
       }
   });
    }
}
